package com.og.ouroa.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.og.ouroa.pojo.entity.CourseBoard;
import com.og.ouroa.mapper.CourseBoardMapper;
import com.og.ouroa.service.CourseBoardService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sun.corba.se.spi.orbutil.threadpool.WorkQueue;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Us
 * @since 2021-12-13
 */
@Service
public class CourseBoardServiceImpl extends ServiceImpl<CourseBoardMapper, CourseBoard> implements CourseBoardService {



    @Override
    public IPage<CourseBoard> getBycid(Page<CourseBoard> pages, Integer cid,Integer pid) {
        QueryWrapper<CourseBoard> wrapper = new QueryWrapper<>();
        wrapper.eq("cid",cid);
        if (pid == null){
            wrapper.eq("pid",0);
        }else {
            wrapper.eq("pid",pid);
        }
        return  baseMapper.selectPage(pages, wrapper);
    }

    @Override
    public void addBoard(CourseBoard courseBoard) {


            baseMapper.insert(courseBoard);
    }

    @Override
    public void removeBoard(Integer bid) {
        baseMapper.deleteById(bid);

    }
}
